#include "threadPool.hpp"
#include "Task.hpp"
#include <ctime>

int Add(int x, int y)
{
    return x + y;
}

// int main()
// {
//     logMessage(NORMAL, "%s, %d, %f\n", "日志信息", 10, 3.14);
//     return 0;
// }

int main()
{
    srand((unsigned)time(nullptr));
    cout << "hello thread pool" << endl;
    ThreadPool<Task> *tp = new ThreadPool<Task>();
    tp->run();

    while (true)
    {
        int x = rand() % 10 + 1;
        usleep(rand() % 1000);
        int y = rand() % 10 + 1;
        Task t(x, y, Add);
        tp->pushTask(t);
        cout << "生产者：" << x << " + " << y << " = ? " << endl;
        // logMessage(DEBUG, "制作完成：%d + %d = ?", x, y);
        sleep(1);
    }

    tp->joins();
    return 0;
}
